<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>登录注册</title>
    <script type="text/javascript" src='/javascripts/jquery-1.9.0.min.js'></script>
    <script type="text/javascript" src="/javascripts/login.js"></script>
    <link href="/stylesheets/login.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <h1>个人博客<sup>blog</sup></h1>
    <div class="login login_pt" >        
        <div class="header">
            <div class="switch" id="switch"><a class="switch_btn_focus" id="switch_qlogin" href="javascript:void(0);" tabindex="7">快速登录</a>
          <a class="switch_btn" id="switch_login" href="javascript:void(0);" tabindex="8">快速注册</a>
          <div class="switch_bottom" id="switch_bottom" style="position: absolute; width: 64px; left: 0px;"></div>
            </div>
        </div>    
        <div class="web_qr_login" id="web_qr_login" style="display: block; height: 235px;">    
              <!--登录-->
              <div class="web_login" id="web_login">  
                 <div class="login-box">
                    <div class="login_form">
                      <form action="" name="loginform" accept-charset="utf-8" id="login_form" class="loginForm" method="post">
                        <input type="hidden" name="did" value="0"/>
                        <input type="hidden" name="to" value="log"/>
                        <div class="uinArea" id="uinArea">
                          <label class="input-tips" for="u">用户名：</label>
                          <div class="inputOuter" id="uArea">
                              <input type="text" id="u" name="u" class="inputstyle"/>
                          </div>
                        </div>
                        <div class="pwdArea" id="pwdArea">
                          <label class="input-tips" for="p">密码：</label> 
                          <div class="inputOuter" id="pArea">
                            <input type="password" id="p" name="p" class="inputstyle"/>
                          </div>
                        </div>
                     
                        <div class="btnwrap">
                          <!-- <input type="button" value="登 录" class="lbtn button_blue"/> -->
                          <span class="lbtn button_blue">登 录</span>
                        </div>
                      </form>
                  </div>
              </div>                   
              </div>    <!--登录end-->
        </div>

      <!--注册-->
        <div class="qlogin" id="qlogin" style="display: none; ">   
          <div class="web_login">
            <form name="form2" id="regUser" accept-charset="utf-8"  action="" method="post">
                <input type="hidden" name="to" value="reg"/>
                <input type="hidden" name="did" value="0"/>
                <ul class="reg_form" id="reg-ul">
                  <div id="userCue" class="cue">请注意格式</div>
                      <li>  
                          <label for="user"  class="input-tips2">用户名：</label>
                          <div class="inputOuter2">
                              <input type="text" id="user" name="user" maxlength="16" class="inputstyle2" placeholder="用户名位4-16字符" />
                          </div>         
                      </li>
                      <li>
                        <label for="passwd" class="input-tips2">密码：</label>
                          <div class="inputOuter2">
                              <input type="password" id="passwd"  name="passwd" maxlength="16" class="inputstyle2" placeholder="密码不能小于6位" />
                          </div>   
                      </li>
                      <li>
                        <label for="passwd2" class="input-tips2">密码确认：</label>
                          <div class="inputOuter2">
                              <input type="password" id="passwd2" name="" maxlength="16" class="inputstyle2" placeholder="再次确认密码" />
                          </div>
                      </li>
                        <div class="btnwrap">
                          <input type="button" value="注 册" class="rebtn button_blue" data-form-sbm="1532517641229.9067">
                        </div>     
                      </li>
                      <div class="cl"></div>
                  </ul>
                </form>
              </div>
        </div>
        <!--注册end-->
    </div>
    <script>
      $(function(){
        // 点击注册按钮
        $('.rebtn').click(function(event) {
          $.ajax({
            url: 'register',
            type: 'post',
            data :{
              name:$('input[name=user]').val(),
              password:$('input[name=passwd]').val()
            },
            success:function(res,err){
              // 注册成功跳转到登陆页面
              $('#switch_login').removeClass("switch_btn_focus").addClass('switch_btn');
              $('#switch_qlogin').removeClass("switch_btn").addClass('switch_btn_focus');
              $('#switch_bottom').animate({left:'0px',width:'70px'});
              $('#qlogin').css('display','none');
              $('#web_qr_login').css('display','block');
              console.log(res);
            },
          })
        })

        // 点击登陆按钮
        $('.lbtn').click(function(event) {
          $.ajax({
            url: '/login',
            type: 'post',
            dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
            data :{
              name:$('input[name=u]').val(),
              password:$('input[name=p]').val()
            },
            success:function(res,status){
              if(status =='success'){
                location.href = 'login'
              }
            },
            error:function(res,err){
              location.href ='register'
            }
          })          
        });

      })
    </script>
  </body>
</html>
